import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import {OrderForm, OrderQuery, Engineer, Examine, ExamineListResult} from '@/api/order/types'

/**
 * 任务订单信息
 *
 * @param queryParams
 */
export function getOrderAwaitList(queryParams?: OrderQuery): AxiosPromise<OptionType[]> {
  return request({
    url: '/web/casualOrder/pages',
    method: 'get',
    params: queryParams,
  });
}

/**
 * 获取服务类型下拉框
 *
 */
export function typeOption(): AxiosPromise<OptionType[]> {
  return request({
    url: '/web/casualServiceType/options',
    method: 'get',
  });
}
/**
 * 获取服务标签下拉框
 *
 * @param queryParams
 */
export function tagOption(queryParams?: any): AxiosPromise<OptionType[]> {
  return request({
    url: '/web/casualServiceLabel/getByIdOption',
    method: 'get',
    params: queryParams,
  });
}
/**
 * 获取企业下拉框
 *
 */
export function firmOption(): AxiosPromise<OptionType[]> {
  return request({
    url: '/web/casualEntrepreneur/options',
    method: 'get',
  });
}
/**
 * 获取个人下拉框
 *
 */
export function personOption(): AxiosPromise<OptionType[]> {
  return request({
    url: '/web/casualPersonage/options',
    method: 'get',
  });
}
/**
 * 新增订单
 *
 * @param queryParams
 */
export function casualOrderAdd(queryParams?: OrderForm) {
  return request({
    url: '/web/casualOrder/add',
    method: 'post',
    data: queryParams,
  });
}
/**
 * 编辑订单
 *
 * @param queryParams
 */
export function casualOrderEdit(queryParams?: OrderForm) {
  return request({
    url: '/web/casualOrder/edit',
    method: 'post',
    data: queryParams,
  });
}
/**
 * 删除订单
 *
 * @param queryParams
 */
export function casualOrderDel(queryParams: any) {
  return request({
    url: '/web/casualOrder/del',
    method: 'get',
    params: queryParams,
  });
}
/**
 * 发布订单
 *
 * @param id
 */
export function releaseOrder(id: string | number) {
  return request({
    url: '/web/casualOrder/releaseOrder?order_id=' + id,
    method: 'get',
  });
}
/**
 * 根据订单ID 查询抢单的用户
 *
 * @param queryParams:any
 */
export function casualOrderEngineerList(queryParams: any): AxiosPromise<Engineer[]> {
  return request({
    url: '/web/casualOrder/casualOrderEngineerList',
    method: 'get',
    params: queryParams
  });
}
/**
 * 查询所有的用户不分页
 *
 * @param queryParams
 */
export function casualEngineerList(queryParams: any): AxiosPromise<Engineer[]> {
  return request({
    url: '/web/casualEngineer/list',
    method: 'get',
    params: queryParams
  });
}
/**
 * 订单明细新增
 *
 * @param queryParams
 */
export function orderItemAdd(queryParams: any) {
  return request({
    url: '/web/casualOrder/orderItemAdd',
    method: 'get',
    params: queryParams
  });
}

/**
 * 订单明细修改
 *
 * @param queryParams
 */
export function orderItemUpadte(queryParams: any) {
  return request({
    url: '/web/casualOrder/orderItemUpadte',
    method: 'get',
    params: queryParams
  });
}
/**
 * 根据订单id 查询订单明细数据
 *
 * @param queryParams
 */
export function getByOrderId(id: string | number) {
  return request({
    url: '/web/casualOrder/getorderItems?order_id=' + id,
    method: 'get',
  });
}
/**
 * 查询首页数据包括注册数量、订单数和两个榜单
 * @returns
 */
export function getCasualOrderIndex(params: any) {
  return request({
    url: '/web/casualOrder/index',
    method: 'get',
    params
  });
}
/**
 * 强制关闭（终止订单）
 *
 * @param queryParams
 */
export function terminationOrder(id: string | number) {
  return request({
    url: '/web/casualOrder/terminationOrder?order_id=' + id,
    method: 'get',
  });
}
/**
 * 取消订单
 *
 * @param queryParams
 */
export function cancellationOrder(id: string | number) {
  return request({
    url: '/web/casualOrder/cancellationOrder?order_id=' + id,
    method: 'get',
  });
}
/**
 * 完成订单
 *
 * @param queryParams
 */
export function completedOrder(id: string | number) {
  return request({
    url: '/web/casualOrder/CompletedOrder?order_id=' + id,
    method: 'get',
  });
}
/**
 * 根据订单id查询已完成的订单结算详情
 *
 * @param queryParams
 */
export function listOrderSettlementItem(id: string | number) {
  return request({
    url: '/web/casualOrder/listOrderSettlementItem?order_id=' + id,
    method: 'get',
  });
}
/**
 * 订单结算保存
 *
 * @param queryParams
 */
export function payOrder(queryParams: any) {
  return request({
    url: '/web/casualOrder/payOrder',
    method: 'post',
    data: queryParams
  });
}
/**
 * 任务订单根据id查询
 *
 * @param queryParams
 */
export function orderGetById(id: number | string) {
  return request({
    url: '/web/casualOrder/getById?id=' + id,
    method: 'get',
  });
}
/**
 * 审核完成导出
 *
 * @param queryParams
 */
export function orderSettlementExport(id: number | string) {
  return request({
    url: '/web/casualOrder/orderSettlementExport/?orderIds=' + id,
    method: 'get',
    responseType: 'blob'
  });
}

/**
 * 财务报税数据导出
 */
export function financeExamineExport(id: number | string) {
  return request({
    url: '/web/casualOrder/financeExamineExport/?orderIds=' + id,
    method: 'get',
    responseType: 'blob'
  });
}

/**
 * 全部审核订单导出
 *
 * @param queryParams
 */
export function orderSettlementAllExport(id: number | string) {
  return request({
    url: '/web/casualOrder/orderSettlementAllExport/?orderIds=' + id,
    method: 'get',
    responseType: 'blob'
  });
}
/**
 * 任务订单根据id查询
 *
 * @param queryParams
 */
export function orderGetCasualCheckRecord() {
  return request({
    url: '/web/casual_check_record/options',
    method: 'get',
  });
}



export function settlementSubmission(id: number | string) {
  return request({
    url: '/LowerSingleEnd/web/casualOrder/listOrderPay',
    method: 'get',
    params: { order_id: id },
  })
}

export function listOrderItem(id: number | string, engineer_id: number | string) {
  return request({
    url: '/web/casualOrder/listOrderItem?order_id=' + id + '&engineer_id=' + engineer_id,
    method: 'get',
  });
}

export function examineList(orderId: number | string): AxiosPromise<Examine[]> {
  return request({
    url: '/web/casual_check_record/reviewNodes',
    method: 'get',
    params: { orderId: orderId },
  })
}





